#ifndef LOG_H_
#define LOG_H_

#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdarg.h>

typedef enum {
	PACMEN_LOG_ERROR,
	PACMEN_LOG_INFO,
	PACMEN_LOG_DEBUG
} pacmen_log_level;

typedef enum {
	PACMEN_LOG_STDOUT,
	PACMEN_LOG_STDERR,
	PACMEN_LOG_FILE
} pacmen_log_output;

typedef struct {
	const char *function;
	int line;
	const char *file;
} pacmen_log_fileattribute;

#define PACMEN_LOG_FILEATTRIBUTE log_controller::file_attribute(__FILE__, __FUNCTION__, __LINE__)

class log_controller {
public:
	log_controller(pacmen_log_level level, pacmen_log_output output);
	log_controller(pacmen_log_level level, const char *filename);
	log_controller();
	virtual ~log_controller();
	void print(pacmen_log_level log_level, const char *str, ...);
	void print(pacmen_log_level log_level, pacmen_log_fileattribute file_attribute, const char *str, ...);

	static pacmen_log_fileattribute file_attribute(const char *file, const char *function, int line);

	log_controller & operator <<(int value);
	log_controller & operator >>(int value);
	log_controller & operator <<(const char *str);
	log_controller & operator >>(const char *str);
	log_controller & operator <<(double value);
	log_controller & operator >>(double value);

	pacmen_log_level log_level;
	pacmen_log_output log_output;
	FILE * output_file;
};

extern log_controller log_config;

#endif /* LOG_H_ */
